package com.jeecg.p3.divination.service.impl;

import com.jeecg.p3.divination.dao.WxActDivinationRegistrationDao;
import com.jeecg.p3.divination.entity.WxActDivinationRegistration;
import com.jeecg.p3.divination.service.WxActDivinationRegistrationService;
import org.jeecgframework.p3.core.utils.common.PageList;
import org.jeecgframework.p3.core.utils.common.PageQuery;
import org.jeecgframework.p3.core.utils.common.PageQueryWrapper;
import org.jeecgframework.p3.core.utils.common.Pagenation;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述：</b>摇签注册表<br>
 * @author：weijian.zhang
 * @since：2018年03月13日 13时57分17秒 星期二 
 * @version:1.0
 */
@Service("wxActDivinationRegistrationService")
public class WxActDivinationRegistrationServiceImpl implements WxActDivinationRegistrationService {
	@Resource
	private WxActDivinationRegistrationDao wxActDivinationRegistrationDao;

	@Override
	public void doAdd(WxActDivinationRegistration wxActDivinationRegistration) {
		wxActDivinationRegistrationDao.insert(wxActDivinationRegistration);
	}

	@Override
	public void doEdit(WxActDivinationRegistration wxActDivinationRegistration) {
		wxActDivinationRegistrationDao.update(wxActDivinationRegistration);
	}

	@Override
	public void doDelete(String id) {
		wxActDivinationRegistrationDao.delete(id);
	}

	@Override
	public WxActDivinationRegistration queryById(String id) {
		WxActDivinationRegistration wxActDivinationRegistration  = wxActDivinationRegistrationDao.get(id);
		return wxActDivinationRegistration;
	}

	@Override
	public PageList<WxActDivinationRegistration> queryPageList(
		PageQuery<WxActDivinationRegistration> pageQuery) {
		PageList<WxActDivinationRegistration> result = new PageList<WxActDivinationRegistration>();
		Integer itemCount = wxActDivinationRegistrationDao.count(pageQuery);
		PageQueryWrapper<WxActDivinationRegistration> wrapper = new PageQueryWrapper<>(pageQuery.getPageNo(), pageQuery.getPageSize(),itemCount, pageQuery.getQuery());
		List<WxActDivinationRegistration> list = wxActDivinationRegistrationDao.queryPageList(wrapper);
		Pagenation pagenation = new Pagenation(pageQuery.getPageNo(), itemCount, pageQuery.getPageSize());
		result.setPagenation(pagenation);
		result.setValues(list);
		return result;
	}

	//根据参与人的openid和活动id查询访问人的报名信息
	@Override
	public WxActDivinationRegistration queryRegistrationByOpenidAndActId(String openid, String actId) {
		return wxActDivinationRegistrationDao.queryRegistrationByOpenidAndActId(openid,actId);
	}
	
}
